<?php include_once './application/views/sys_admin/common/header.php';  ?>
<div class=" definewidth m20">
	<form  method="post" id="siteForm" name="siteForm">
	<font color="red"><?php echo @validation_errors(); ?></font>
		<table class="table table-bordered table-hover m10">
			<tr>
		        <td class="tableleft">分类名称 </td>
		        <td><input type="text" name="title" id="title" size="50"  value="<?php echo @set_value('title');?>" /> </td>
		    </tr>
		    <tr>
		        <td class="tableleft">上级分类 </td>
		        <td> 
		        <select  id="parent_id" name="parent_id">
					<option value="0">顶级分类</option>
					<?php foreach ($site_array as $val){  ?>
						<option value="<?php echo $val['id']?>" ><?php echo $val['title']?></option>
						<?php if(isset($val['category_list']) && is_array($val['category_list']) && count($val['category_list'])>0){
							foreach ($val['category_list'] as $v){
							?>
							<option value="<?php echo $v['id']?>" >&nbsp;&nbsp;&nbsp;<?php echo $v['title']?></option>	
						<?php }}?>
					<?php }?>
				</select>
		        </td>
		    </tr>
		    <tr>
		        <td class="tableleft">url </td>
		        <td><input type="text" name="url" id="url" value="" /> </td>
		    </tr>
		    <tr>
		        <td class="tableleft">排序 </td>
		        <td><input type="text" name="forder" id="forder" value="<?php echo @set_value('forder')?set_value('forder'):0;?>" /> </td>
		    </tr>
		    <tr>
		        <td class="tableleft">分类属性 </td>
		        <td>
		        <input type="radio" checked="checked" id="type_set_0" value="0" name="type_set"  onclick="type_set_click(this);"/>
				<label for="type_set_0">单页</label>
				<input type="radio" id="type_set_1" value="1" name="type_set"  onclick="type_set_click(this);"/>
				<label for="type_set_1">列表页</label>
		         </td>
		    </tr>
		    <tr>
		        <td class="tableleft">内容 </td>
		        <td>
		        <script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.config.js"></script>
    				<script type="text/javascript" charset="utf-8" src="/static/ueditor/ueditor.all.js"></script>
    				<script type="text/javascript" charset="utf-8">
			          var editor = new baidu.editor.ui.Editor();
			          editor.render('content');  //editor为编辑器容器的id
			      </script>
				<textarea name="content" id="content" style="width:800px" >
				<?php echo @set_value('content');?>
				</textarea>
		         </td>
		    </tr>
		    <tr>
		        <td class="tableleft"> </td>
		        <td><button type="button" class="btn btn-success"  onclick="siteSubmit();" >提交</button></td>
		    </tr>
		</table>
	</form>
</div>
<script type="text/javascript">
function type_set_click(_this) {
	var typeid = $(_this).val();
	
	if(typeid == 0){
		$("#site_content").css("display","");
	}else{
		$("#site_content").css("display","none");
	}
	
}

function siteSubmit(){
	var options = {
		url : '/sys_admin/site/add/',
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg=='1'){
				alert("操作成功");
				window.location.href ='/sys_admin/site/zhs_sitelist';
			}else{
				alert(ret.msg);
			}
			
		}
	};
	$("#siteForm").ajaxSubmit(options);
	return false;
}
</script>
<div id="dialog" title="系统提示" style="display:none"><p id="msg" style="text-align:center"></p></div>
